﻿using System;

namespace ParsePtb.attr
{
    //验证的特性
    [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
    public class VerifyAttr : Attribute
    {
        //验证是null
        bool nullable = false;

        //小于0 则不验证
        int maxLength = -1;

        //中文注释==> 用于验证提示
        string columCnm;

        //正则验证
        string pattern;

        //业务区分
        string[] businessDiff;

        //仅提示[默认为false]
        bool promptOnly = false;

        //验证重复性
        bool repeat = false;

        public VerifyAttr(int maxLength, string columCnm)
        {
            this.MaxLength = maxLength;
            this.ColumCnm = columCnm;
        }

        /// <summary>
        /// 长度--中文注释--业务区分
        /// </summary>
        /// <param name="maxLength"></param>
        /// <param name="columCnm"></param>
        /// <param name="businessDiff"></param>
        public VerifyAttr(int maxLength, string columCnm, string[] businessDiff)
        {
            this.MaxLength = maxLength;
            this.ColumCnm = columCnm;
            this.businessDiff = businessDiff;
        }

        /// <summary>
        /// 长度--中文注释--业务区分--仅提示验证
        /// </summary>
        /// <param name="maxLength"></param>
        /// <param name="columCnm"></param>
        /// <param name="businessDiff"></param>
        public VerifyAttr(int maxLength, string columCnm, string[] businessDiff, bool promptOnly)
        {
            this.MaxLength = maxLength;
            this.ColumCnm = columCnm;
            this.businessDiff = businessDiff;
            this.promptOnly = promptOnly;
        }


        /// <summary>
        /// 长度--中文注释--业务区分--仅提示验证--是否重复
        /// </summary>
        /// <param name="maxLength"></param>
        /// <param name="columCnm"></param>
        /// <param name="businessDiff"></param>
        public VerifyAttr(int maxLength, string columCnm, string[] businessDiff, bool promptOnly, bool repeat)
        {
            this.MaxLength = maxLength;
            this.ColumCnm = columCnm;
            this.businessDiff = businessDiff;
            this.promptOnly = promptOnly;
            this.Repeat = repeat;
        }


        /// <summary>
        ///  验证非空--长度--中文注释
        /// </summary>
        /// <param name="nullable"></param>
        /// <param name="maxLength"></param>
        /// <param name="columCnm"></param>
        public VerifyAttr(bool nullable, int maxLength, string columCnm)
        {
            this.Nullable = nullable;
            this.MaxLength = maxLength;
            this.ColumCnm = columCnm;
        }

        /// <summary>
        ///  是否非空--长度--中文注释--业务区分
        /// </summary>
        /// <param name="nullable"></param>
        /// <param name="maxLength"></param>
        /// <param name="columCnm"></param>
        /// <param name="businessDiff"></param>
        public VerifyAttr(bool nullable, int maxLength, string columCnm, string[] businessDiff)
        {
            this.Nullable = nullable;
            this.MaxLength = maxLength;
            this.ColumCnm = columCnm;
            this.businessDiff = businessDiff;
        }

        /// <summary>
        ///  是否非空--长度--中文注释--正则验证
        /// </summary>
        /// <param name="nullable"></param>
        /// <param name="maxLength"></param>
        /// <param name="columCnm"></param>
        /// <param name="pattern"></param>
        public VerifyAttr(bool nullable, int maxLength, string columCnm, string pattern)
        {
            this.Nullable = nullable;
            this.MaxLength = maxLength;
            this.ColumCnm = columCnm;
            this.Pattern = pattern;
        }

        /// <summary>
        /// 是否非空--长度--中文注释--正则验证--业务区分
        /// </summary>
        /// <param name="nullable"></param>
        /// <param name="maxLength"></param>
        /// <param name="columCnm"></param>
        /// <param name="pattern"></param>
        /// <param name="businessDiff"></param>
        public VerifyAttr(bool nullable, int maxLength, string columCnm, string pattern, string[] businessDiff)
        {
            this.Nullable = nullable;
            this.MaxLength = maxLength;
            this.ColumCnm = columCnm;
            this.Pattern = pattern;
            this.businessDiff = businessDiff;
        }

        public bool Nullable { get => nullable; set => nullable = value; }
        public int MaxLength { get => maxLength; set => maxLength = value; }
        public string ColumCnm { get => columCnm; set => columCnm = value; }
        public string Pattern { get => pattern; set => pattern = value; }
        public string[] BusinessDiff { get => businessDiff; set => businessDiff = value; }
        public bool PromptOnly { get => promptOnly; set => promptOnly = value; }
        public bool Repeat { get => repeat; set => repeat = value; }
    }
}
